package com.sky.controller.user;


import com.sky.context.BaseContext;
import com.sky.dto.UserLoginDTO;
import com.sky.result.Result;
import com.sky.service.UserService;
import com.sky.vo.UserLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "用户接口")
@Slf4j
@RequestMapping("/user/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户登录
     * @param dto
     * @return
     */
    @ApiOperation("用户登录")
    @PostMapping("/login")
    public Result Login(@RequestBody UserLoginDTO dto){

        UserLoginVO vo = userService.login(dto);

        log.info("当前用户id为{}：", BaseContext.getCurrentId());
        return Result.success(vo);
    }




}
